<style>
	TD, TH
	{
		min-height	:	20px;
		min-width	:	20px;
		padding		:	5px;
	}

	/*
		Sides:
		not set		:	undefined
		0			:	empty
		1			:	wall
	*/
	.side0,
	.sideUp
	{
		border-top-color	:	#FF0000;
	}
	.side00,
	.sideUp0
	{
		border-top-color	:	#FFFFFF;
	}
	.side01,
	.sideUp1
	{
		border-top-color	:	#000000;
	}
	.side1,
	.sideRight
	{
		border-right-color	:	#FF0000;
	}
	.side10,
	.sideRight0
	{
		border-right-color	:	#FFFFFF;
	}
	.side11,
	.sideRight1
	{
		border-right-color	:	#000000;
	}
	.side2,
	.sideDown
	{
		border-bottom-color	:	#FF0000;
	}
	.side20,
	.sideDown0
	{
		border-bottom-color	:	#FFFFFF;
	}
	.side21,
	.sideDown1
	{
		border-bottom-color	:	#000000;
	}
	.side3,
	.sideLeft
	{
		border-left-color	:	#FF0000;
	}
	.side30,
	.sideLeft0
	{
		border-left-color	:	#FFFFFF;
	}
	.side31,
	.sideLeft1
	{
		border-left-color	:	#000000;
	}
	.cellIsVisited
	{
		background-color	:	#FFFF99;
	}
	.cellIsNotVisited
	{
		background-color	:	#FFFFFF;
	}
	.cellIsInaccessible
	{
		background-color	:	#CCCCCC;
	}

</style>

<?php
	error_reporting(E_ALL);

	require_once('Map.php');

	//NOTE: Code with sides as individual properties
	function getSideClass($side, $type)
	{
		return 'side' . $side . $type;
	}

	$startTime				=	microtime(true);
	$width					=	25;
	$height					=	25;
	$directionModifier		=	30;
	$sparsenessModifier		=	70;
	$deadEndRemovalModifier	=	100;
	$map				=	new Map($width, $height, $directionModifier, $sparsenessModifier, $deadEndRemovalModifier);
	$executionTime		=	microtime(true) - $startTime;

	echo('<table cellpadding="5" cellspacing="0" border="1">');

	echo('<tr>');
	echo('<th>(x,y)</th>');

	for ($i=0; $i<$width; $i++)
	{
		echo('<th>' . $i . '</th>');
	}

	echo('</tr>');

	for ($row=0; $row<$height; $row++)
	{
		echo('<tr>');
		echo('<th>' . $row  . '</th>');

		for ($column=0; $column<$width; $column++)
		{
			$wallCount	=	0;
			$cell		=	$map->getCell(new Point($column, $row));
			$classes	=	array();

			array_push($classes, $cell->visited		?	'cellIsVisited'	:	'cellIsNotVisited');

			//NOTE: Code with sides as array
			for ($i=0; $i<Direction::TOTAL_DIRECTIONS; $i++)
			{
				array_push($classes, 'side' . $i . $cell->sides[$i]);

				if ($cell->sides[$i] == SideType::WALL)
				{
					$wallCount++;
				}
			}

			if ($wallCount == Direction::TOTAL_DIRECTIONS)
			{
				array_push($classes, 'cellIsInaccessible');
			}

/*
			//NOTE: Code with sides as individual properties
			array_push($classes, getSideClass('Up',		$cell->sideUp));
			array_push($classes, getSideClass('Right',	$cell->sideRight));
			array_push($classes, getSideClass('Down',	$cell->sideDown));
			array_push($classes, getSideClass('Left',	$cell->sideLeft));

			if ($cell->sideUp == SideType::WALL && $cell->sideRight == SideType::WALL && $cell->sideDown == SideType::WALL && $cell->sideLeft == SideType::WALL)
			{
				array_push($classes, 'cellIsInaccessible');
			}
*/

			echo('<td class="');

			foreach($classes as $class)
			{
				echo($class . ' ');
			}

			echo('"></td>');
		}

		echo('</tr>');
	}

	echo('</table>');